package com.chexiehui.jc.mvp.login;

import com.chexiehui.jc.Constants;
import com.chexiehui.jc.base.BaseModel;
import com.chexiehui.jc.base.BaseView;
import com.chexiehui.jc.entity.AuthInfo;
import com.chexiehui.jc.entity.UserInfo;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

/**
 * @Description 登录
 * @Auth SongJun
 * @Date 2019/11/20 10:05
 **/
public interface LoginCovenant {

    interface View extends BaseView {
        void onGetCodeByPhoneLoginSuccess(BaseModel<Object> successResult);

        void onGetCodeByPhoneLoginFailure(BaseModel<Object> failureResult);

        void onPhoneLoginSuccess(BaseModel<AuthInfo> successResult);

        void onPhoneLoginFailure(BaseModel<Object> failureResult);

        void onAccountLoginSuccess(BaseModel<AuthInfo> successResult);

        void onAccountLoginFailure(BaseModel<Object> failureResult);

        void onGetUserInfoSuccess(BaseModel<UserInfo> successResult);

        void onGetUserInfoFailure(BaseModel<Object> failureResult);

        String getIm();
    }

    interface Stores {
        @FormUrlEncoded
        @POST(Constants.SEND_CODE)
        Observable<BaseModel<Object>> getCode(
                @Field("phone") String phone);

        @FormUrlEncoded
        @POST(Constants.URL_LOGIN_BY_PHONE)
        Observable<BaseModel<AuthInfo>> phoneLogin(
                @Field("phone") String phone,
                @Field("code") String code,
                @Field("im") String im);

        @FormUrlEncoded
        @POST(Constants.URL_LOGIN_BY_ACCOUNT)
        Observable<BaseModel<AuthInfo>> accountLogin(
                @Field("userid") String userid,
                @Field("password") String password,
                @Field("im") String im);

        @FormUrlEncoded
        @POST(Constants.URL_GET_USER_INFO)
        Observable<BaseModel<UserInfo>> getUserInfo(@Field("timespan") String timespan);

    }

    interface Presenter {
        void getCodeByPhoneLogin(String phone);
        void phoneLogin(String phone, String code);
        void accountLogin(String phone, String password);
        void getUserInfo();
    }

}